<template>
	<view>
		<uni-nav-bar :fixed="true" left-icon="back" title="消息通知" @clickLeft="leftBack" background-color="#318cff" color="#fff"></uni-nav-bar>
		<view class="dfj-pd-lr-30 dfj-pd-b-50">
			<block v-for="(item,index) in list">
				<view>
					<view class="dfj-pd-tb-20 dfj-t-c">
						<text class="dfj-bg-e1e dfj-t-white dfj-inline-block dfj-pd-tb-10 dfj-pd-lr-30 dfj-bd-radius-30">{{ item.createDate | timestampToTime }}</text>
					</view>
					<view class="dfj-bg-white dfj-bd-radius-15 dfj-pd-20">
						<view class="dfj-t-333 dfj-f-35">{{ item.title }}</view>
						<view class="dfj-t-999 dfj-mg-t-15">{{ item.content }}</view>
					</view>
				</view>
			</block>

		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				list: [],
				type: 1,
				page: 1
			}
		},
		filters:{
			filtersJumpType(val){
				let txt;
				if(val == 1){
					txt = '账户通知'
				}else if(val == 2){
					txt = '服务通知'
				}else if(val == 3){
					txt = '交易物流'
				}
				return txt;
			},
			timestampToTime(timestamp) {
				var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = date.getDate() + ' ';
				var h = date.getHours() + ':';
				var m = date.getMinutes() + ':';
				var s = date.getSeconds();
				return Y + M + D + h + m + s;
			}
		},
		onLoad(options) {
			this.type = options.type
			this.getList()
		},
		methods:{
			leftBack() {
				uni.navigateBack();
			},
			getList() {
				this.$http({
					url: '/userOpt/queryPushMessageList',
					data: {
						type: this.type,
						page: this.page
					}
				}).then(res=>{
					if(res.data.list.length>0){
						this.page++;
						this.list.push(...res.data.list)
					}
				})
			}
		},
		onReachBottom() {
			this.getList()
		}
	}
</script>

<style>
</style>
